<body>
    <div class="x-body">
        <form class="layui-form">
          <div class="layui-form-item">
              <label for="username" class="layui-form-label">
                  <span class="x-red">*</span>网站名
              </label>
              <div class="layui-input-inline">
                  <input type="text" id="username" name="name" required="" lay-verify="required"
                  autocomplete="off" value="{$site.name}" class="layui-input">
              </div>
          </div>
          <div class="layui-form-item">
              <label for="phone" class="layui-form-label">
                  <span class="x-red">*</span>缓存参数
              </label>
              <div class="layui-input-inline">
                  <input type="text" id="phone" name="v" required="" lay-verify="required" value="{$site.v}"
                  autocomplete="off" class="layui-input">
              </div>
          </div>
          <div class="layui-form-item">
              <label for="L_email" class="layui-form-label">
                  <span class="x-red">*</span>网站根目录
              </label>
              <div class="layui-input-inline">
                  <input type="text" id="L_email" name="root_path" required="" lay-verify="required"
                  autocomplete="off" value="{$site.root_path}" class="layui-input">
              </div>
              <div class="layui-form-mid layui-word-aux">
                  <span class="x-red">*</span>
              </div>
          </div>
         
          <div class="layui-form-item">
              <label for="L_pass" class="layui-form-label">
                  <span class="x-red">*</span>版本
              </label>
              <div class="layui-input-inline">
                  <input type="text" id="L_pass" name="version" required="" lay-verify="required" value="{$site.version}"
                  autocomplete="off" class="layui-input">
              </div>
          </div>
          <div class="layui-form-item">
              <label for="L_repass" class="layui-form-label">
                  <span class="x-red">*</span>网站域名
              </label>
              <div class="layui-input-inline">
                  <input type="text" id="L_repass" name="host" required="" lay-verify="required" value="{$site.host}"
                  autocomplete="off" class="layui-input">
              </div>
          </div>
          <div class="layui-form-item">
              <label for="L_repass" class="layui-form-label">
              </label>
              <button  class="layui-btn" lay-filter="add" lay-submit="">
                  保存
              </button>
          </div>
      </form>
    </div>
    <script>
        layui.use(['form','layer'], function(){
            $ = layui.jquery;
          var form = layui.form
          ,layer = layui.layer;
        


          //监听提交
          form.on('submit(add)', function(data){
            console.log(data.field);
            //发异步，把数据提交给php
            $.post('{:url('admin/set/base')}',data.field, function(res, textStatus, xhr) {
                   if(res.code==1){

                        layer.alert(res.msg, {icon: 6},function(){
                            layer.closeAll()
                        });
                    }else{
                        $('#code').click();
                        layer.msg(res.msg, function(){});
                    }
            },'json');
            
           
            return false;
          });
          
          
        });
    </script>
  </body>

</html>